package com.jqing.lib.widget;

import android.content.Context;
import android.graphics.drawable.AnimationDrawable;
import android.util.AttributeSet;
import android.widget.ImageView;

/**
 * Created by chshqiang on 15-1-22.
 * 加载等待控件
 */
public class JqLoadingView extends ImageView {
    private AnimationDrawable animationDrawable;

    public JqLoadingView(Context context) {
        super(context);
    }

    public JqLoadingView(Context context, AttributeSet attrs) {
        super(context, attrs);

        setAnimationDrawable();
    }

    public JqLoadingView(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);

        setAnimationDrawable();
    }

    public void setAnimationDrawable() {
        animationDrawable = (AnimationDrawable) getDrawable();

        animationDrawable.start();
    }

    public void startAnimationDrawable() {
        setAnimationDrawable();
    }

    public void stopAnimationDrawable() {
        animationDrawable.stop();

        animationDrawable = null;
    }
}
